package com.freedy.algorithm.prim;

/**
 * @author Freedy
 * @date 2021/4/13 21:50
 */
public class MGraph {
    int verxs;//节点的个数
    char[] data;//存放在节点的数据
    int[][] weight;//存放边，就是我们的邻接矩阵


    public MGraph(char[] data,int[][] weight) {
        if (data.length!=weight.length||weight[0].length!=weight.length)
            throw new RuntimeException("传入的数据不匹配!");
        this.verxs = data.length;
        this.data=data;
        this.weight=weight;
    }

    public void printGraph(){
        for (int i = -1; i < weight.length; i++) {
            for (int j = -1; j < weight[0].length; j++) {
                if (i==-1){
                    System.out.print(j==-1?"  ":data[j]+" ");
                }else if (j==-1){
                    System.out.print(data[i]+" ");
                } else {
                    System.out.print(weight[i][j]+" ");
                }
            }
            System.out.println();
        }
    }
}
